import java.util.Scanner;

public class Test2 {
//    输出水仙花数
    public static void main(String[] args) {
        for(int i = 0;i < 999999;i++){
            int count = 0;
            int tmp = i;
            while(i / 10 != 0){
                count++;
                tmp /= 10;
            }
            tmp = i;
            int sum = 0;
            while(tmp != 0){
                sum += Math.pow((tmp % 10),count);
                tmp /= 10;
            }
            if(sum == i){
                System.out.println(i + "是水仙花数");
            }
        }
    }



    public static void print(int a,int b){
        System.out.print(a + " " + b);
        System.out.println();
    }

    public static void print(int a,int b,int c){
        System.out.print(a + " " + b + " " + c);
        System.out.println();
    }

//    可变参数编程
    public static void print(int ... k){
        for(int i = 0;i < k.length;i++){
            System.out.print(k[i] + " ");
        }
        System.out.println();
    }

    public static void main4(String[] args) {
        print(1,2);
        print(1,2,3);
        print(1,2,3,4);
        print(1,2,3,4,5,6,7,8,9,10);
    }





    public static int max(int a,int b){
        return a > b? a : b;
    }

    public static int max(int a,int b,int c){
//        int tmp = max(a,b);
//        return max(tmp,c);
        return c > (a > b? a : b)? c : a > b? a : b;
    }

    public static void main3(String[] args) {
        Scanner scan = new Scanner(System.in);
        int a = scan.nextInt();
        int b = scan.nextInt();
        int c = scan.nextInt();

        System.out.println(max(a,b,c));

    }



//    求一个数的阶乘

    public static  int facSum(int n){
        int sum = 0;
        for(int i = 1;i <= n;i++){
            sum += fac(i);
        }
        return sum;
    }

    public static int fac(int n){
        int ret = 1;
        for(int i = 1;i <= n;i++){
            ret *= i;
        }
        return ret;
    }

    public static void main2(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int ret = fac(n);
        int sum = facSum(n);
        System.out.println(ret);
        System.out.println(facSum(5));
        System.out.println(sum);
    }





    public static int add(int a,int b){
        return a + b;
    }

    /**
     * 方法名采用小驼峰的形式：maxNum
     * @param year
     * @return
     */
    public static boolean isLeapYear(int year){
        if(year % 4 == 0 && year % 100 != 0 || year % 400 == 0){
            return true;
        }
        return false;
    }


    public static void main1(String[] args) {
        Scanner scan = new Scanner(System.in);
        int a = scan.nextInt();
        int b = scan.nextInt();
        int ret = add(a,b);
        System.out.println(ret);

        int year = scan.nextInt();
        boolean flag = isLeapYear(year);
        if(flag){
            System.out.println(year + "是闰年");
        }
        else{
            System.out.println(year + "不是闰年");
        }

    }





}
